import api from "./init";
import {AxiosResponse} from "axios";
import {Result} from "@/types/api-common";
import {
    EmojiPackItemUpdateRequest, UserEmojiPackItemCreateResponse,
    UserEmojiPackItemResponse,
    UserEmojiPackItemUpdateResponse, UserEmojiPackResponse
} from "@/types/user-emoji";

/**
 * 获取用户表情包信息
 * @returns {Promise<Result<UserEmojiPackResponse>>} 用户表情包信息
 */
export const getUserEmojiPackApi = async (): Promise<AxiosResponse<Result<UserEmojiPackResponse>>> => {
    return api.get('/emoji/pack');
};

// 根据表情包ID获取表情包项列表
export const getUserEmojisApi = async (): Promise<AxiosResponse<Result<UserEmojiPackItemResponse[]>>> => {
    return api.get('/emoji/item');
};

// 上传新的收藏表情包
export const uploadEmojiPackApi = async (formData: FormData) : Promise<AxiosResponse<Result<UserEmojiPackItemCreateResponse>>> => {
    return api.post('/emoji/item',
        formData,
        {
            headers: {
                "Content-Type": "multipart/form-data",
            },
        })
}


// 删除收藏的表情包项
export const deleteEmojiItemApi = async (emojiId: string): Promise<AxiosResponse<Result<UserEmojiPackItemUpdateResponse>>> => {
    return api.delete(`/emoji/item/${emojiId}`);
};

// 更新收藏的表情包项的排序
export const updateEmojiItemApi = async (data: EmojiPackItemUpdateRequest): Promise<AxiosResponse<Result<UserEmojiPackItemUpdateResponse>>> => {
    return api.put('/emoji/item', data);
};